package it.fuesi.expired.api;

import java.util.LinkedList;
import java.util.List;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.FormHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
@EnableWebMvc
@ComponentScan({ "it.fuesi.expired.api" })
public class Application extends WebMvcConfigurerAdapter {

    public Application() {
        super();
    }

    @Override
    public void configureMessageConverters(final List<HttpMessageConverter<?>> messageConverters) {
    	MappingJackson2HttpMessageConverter jsonConv = new MappingJackson2HttpMessageConverter();
    	
        
        ByteArrayHttpMessageConverter conv = new ByteArrayHttpMessageConverter();
        
//        List<MediaType> mediaTypes = new LinkedList<MediaType>();
//        mediaTypes.add(MediaType.IMAGE_JPEG);
//        mediaTypes.add(MediaType.IMAGE_PNG);
//        conv.setSupportedMediaTypes(mediaTypes);
//        
        messageConverters.add(conv);
        
        FormHttpMessageConverter formConv = new FormHttpMessageConverter();
		formConv.addPartConverter(jsonConv);
		
		messageConverters.add(formConv);
		messageConverters.add(jsonConv);

        super.configureMessageConverters(messageConverters);
    }
    
    

}